{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "sys.path.append(\".\")\n",
    "\n",
    "import pickle\n",
    "import pandas as pd\n",
    "from get_important_pr_candidates import PrStat"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "file = open(\"prlist\",\"rb\") # open the pickled file\n",
    "selected_prs = pickle.load(file)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "rows = pd.DataFrame()\n",
    "\n",
    "for pr_stat in selected_prs:\n",
    "    data = {\n",
    "        'number': [pr_stat.pull_request.number],\n",
    "        'url': [pr_stat.pull_request.html_url],\n",
    "        'title': [pr_stat.pull_request.title],\n",
    "        'overall_score': [pr_stat.score],\n",
    "        'label_score': [pr_stat.label_score],\n",
    "        'length_score': [pr_stat.length_score],\n",
    "        'body_length': [pr_stat.body_length],\n",
    "        'comment_length': [pr_stat.comment_length],\n",
    "        'interaction_score': [pr_stat.interaction_score],\n",
    "        'comments': [pr_stat.num_comments],\n",
    "        'reactions': [pr_stat.num_reactions],\n",
    "        'reviews': [pr_stat.num_reviews],\n",
    "        'num_interacting_users': [pr_stat.num_interacting_users],\n",
    "        'change_score': [pr_stat.change_score],\n",
    "        'additions': [pr_stat.num_additions],\n",
    "        'deletions': [pr_stat.num_deletions],\n",
    "        'num_changed_files': [pr_stat.num_changed_files],\n",
    "    }\n",
    "    df = pd.DataFrame(data)\n",
    "    rows = pd.concat([df, rows]).reset_index(drop = True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "rows.to_csv(\"prlist.csv\")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3.8.13 ('venv': venv)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.13"
  },
  "orig_nbformat": 4,
  "vscode": {
   "interpreter": {
    "hash": "5a5b0b9be407356423d180a7e1f3e58a04e66d6eb2f65844600a2a5341048d00"
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
